#pragma once

#include "RNOH/arkui/ArkUINode.h"
#include "RNOH/arkui/StackNode.h"
#include <react/renderer/graphics/Color.h>
#include "RectF.h"
#include "ModUtil.h"
#include <../../Transform.h>

namespace rnoh {
    class DisplayMetrics {
    public:
        float density;

        DisplayMetrics(float density) : density(density) {}
    };

    class TypedValue {
    public:
        static float applyDimension(int unit, float value, const DisplayMetrics &metrics) {
            if (unit == COMPLEX_UNIT_DIP) {
                return value * metrics.density;
            } else {
                return value;
            }
        }

        static const int COMPLEX_UNIT_DIP = 1; 
    };


    class ClipPathViewStackNode : public ArkUINode {
    public:
        ClipPathViewStackNode();

        void insertChild(ArkUINode &child, std::size_t index);
        void removeChild(ArkUINode &child);
        ClipPathViewStackNode &setD(const std::string &);
        ClipPathViewStackNode &setOpacity(const float &);

        ClipPathViewStackNode &setMask(const std::string &);

        ClipPathViewStackNode &setOldMask(const std::string &);

        ClipPathViewStackNode &setFillColor(int const &);

        ClipPathViewStackNode &setFillOpacity(const float &);

        ClipPathViewStackNode &setFillRule(const std::string &);

        ClipPathViewStackNode &setStrokeColor(int const &);

        ClipPathViewStackNode &setStrokeOpacity(float const &);

        ClipPathViewStackNode &setStrokeWidth(float const &);

        ClipPathViewStackNode &setStrokeCap(std::string const &);

        ClipPathViewStackNode &setStrokeJoin(std::string const &);

        ClipPathViewStackNode &setStrokeMiter(float const &);

        ClipPathViewStackNode &setStrokeStart(float const &);

        ClipPathViewStackNode &setStrokeEnd(float const &);

        ClipPathViewStackNode &setShadowColor(int const &);

        ClipPathViewStackNode &setShadowOpacity(float const &);

        ClipPathViewStackNode &setShadowRadius(float const &);

        ClipPathViewStackNode &setShadowOffsetX(float const &);

        ClipPathViewStackNode &setShadowOffsetY(float const &);

        ClipPathViewStackNode &setShadowOffsetIsPercent(bool const &);
    
        ClipPathViewStackNode &setBgColor(int const &);
    
        facebook::react::Transform transformScale;
        rnoh::RectF rectF;
        rnoh::RectF rectFVb, rectFVbDensity;
        rnoh::ModUtil modUtil;

        float translationX = 0.f;
        float translationY = 0.f;
        bool translationIsPercent = false;
        float rotation{0.f};
        float rotationOx{0.f};
        float rotationOy{0.f};
        bool rotationIsPercent{false};
        float scaleX = 1.f;
        float scaleY = 1.f;
        float scaleOriginX = 0.f;
        float scaleOriginY = 0.f;
        bool scaleIsPercent = false;

        std::string align = "xMidYMid";
        float viewBox[4];

        float shadowRadius;
        float shadowOffsetX;
        float shadowOffsetY;
        uint32_t shadowColor;

        void transform();
        bool validateViewBox();
        float toDip(float value);
        void setSc(float v);
        void setScX(float v);
        void setScY(float v);
        void setScO(float v);
        void setScOx(float v);
        void setScOy(float v);
        void setScPercentageValue(bool v);
        void setTransX(float v);
        void setTransY(float v);
        void setTransPercentageValue(bool v);
        void setRot(float v);
        void setRotO(float v);
        void setRotOx(float v);
        void setRotOy(float v);
        void setRotPercentageValue(bool v);

        void setAlign(std::string align);
        void setViewBox(float viewBox[]);
private:
        float getDensity();
    };
} // namespace rnoh